package com.zengqingfa.designpattern.behavior.observer.spring;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 *
 * @fileName: ApplicationContextHolder
 * @author: zengqf3
 * @date: 2021-5-13 13:55
 * @description:
 */
@Component
public class ApplicationContextHolder implements ApplicationContextAware {

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        //容器启动时进行触发
        applicationContext.publishEvent(new Notice("spring 观察者模式"));
    }
}
